<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
    ];

    /**
     * Define the application's command schedule.
     *
     * @param \Illuminate\Console\Scheduling\Schedule $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        //店铺点击量增加
        $schedule->command("shopclick:add")->everyTenMinutes()->runInBackground();
        //商品订单支付超时自动取消
        //$schedule->command("shoporder:cancel")->everyMinute()->withoutOverlapping()->runInBackground();
        //商品订单自动发货
        //$schedule->command("shoporder:delivery")->everyMinute()->withoutOverlapping()->runInBackground();
        //商品订单自动完成
        //$schedule->command("shoporder:complete")->everyMinute()->withoutOverlapping()->runInBackground();


        //$schedule->command('order:overdue')->hourly();
        //$schedule->command('vip:overdue')->everyFiveMinutes(); //VIP过期功能
        //$schedule->command('Invest:profit')->dailyAt('2:00');//理财收益
        //$schedule->command('Ponits:update')->dailyAt('00:01');//更新积分
        //$schedule->command("ethereum0")->everyFiveMinutes()->withoutOverlapping()->runInBackground();//判断ETH授权状态
        //$schedule->command("recharge:trc")->everyMinute()->withoutOverlapping()->runInBackground();  //自动更新充值订单 完成充值
    }

    /*
     * 秒级定时任务  //->runInBackground();
     * 守护进程执行 php artisan short-schedule:run
     * */
    protected function shortSchedule(\Spatie\ShortSchedule\ShortSchedule $shortSchedule)
    {

        //$shortSchedule->command('ceshi')->everySeconds(10);


        // this artisan command will run every second
        //$shortSchedule->command('order:overdue')->everySecond(5);  //超时失败
        //$shortSchedule->command('artisan-command')->everySecond();
        //$shortSchedule->command('payOrder')->everySecond();
        //$shortSchedule->command('artisan-command')->everySeconds(30);
        //$shortSchedule->command('artisan-command')->everySeconds(0.5);
        //$shortSchedule->command('artisan-command')->everySecond()->onOneServer(); 只在一台服务器执行
        //$shortSchedule->command('artisan-command')->everySecond()->withoutOverlapping();  禁止重叠执行
        //$shortSchedule->command('issue:clean')->everySeconds(11);
    }


    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__ . '/Commands');

        require base_path('routes/console.php');
    }
}
